<?php

namespace app\api\controller;

use addons\shopro\service\order\OrderDispatch;
use addons\shopro\service\order\OrderOper;
use addons\shopro\service\user\User as UserService;
use addons\shopro\service\Wallet as WalletService;
use app\admin\model\Children;
use app\admin\model\market\Acceleration;
use app\admin\model\shopro\goods\SkuPrice;
use app\admin\model\shopro\order\Action;
use app\admin\model\shopro\order\Order;
use app\admin\model\shopro\order\OrderItem;
use app\admin\model\shopro\user\WalletLog;
use app\common\controller\Api;
use app\common\model\shopro\CarDetailsModel;
use app\common\model\shopro\CarQueue;
use app\common\model\shopro\DividendLog;
use app\common\model\shopro\ReleaseAccelerateLogModel;
use app\common\model\shopro\ReleaseAccelerateMarketplaceLogModel;
use app\common\model\shopro\ReleaseLog;
use app\common\model\shopro\Shop;
use app\common\model\shopro\ShoproPerformanceModel;
use app\common\model\User;
use app\common\model\Userchildren;
use fast\Http;
use fast\Random;
use think\Db;
use think\exception\HttpResponseException;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\Request;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function ceshi()
    {
//        $data = db('shopro_user_wallet_log')->where(['type'=>'silver','event'=>'release_slive'])->whereTime('createtime','d')->delete();
//        $data = db('user_silver_log')->whereTime('createtime','d')->delete();
//        dump($data);exit();
//        foreach ($data as $k=>$v){
////            dump($v['amount']);
//           $r = db('user')->where(['id'=>$v['user_id']])->setDec('silver',$v['amount']);
//           dump($r);
//        }
        $walletLogModel = new WalletLog();
        $parent_user_id = '2187';
        $children_two =  db('user_children')->where(['member_id'=>$parent_user_id,'level'=>2])->column('children_id');
        if($children_two){
            $cj_amount = $walletLogModel->whereIn('user_id', $children_two)->where(['event'   => 'release', 'type'    => 'score'])->whereTime('createtime', 'd')->sum('amount');
            if($cj_amount){
                $cj_amount = abs($cj_amount);
                dump($cj_amount);exit();
                $sumScoresTwo[$parent_user_id] = $cj_amount;
            }
        }
    }

}
